package pers.lx.crm.dao.business;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import pers.lx.crm.entiy.business.BusinessDO;
import pers.lx.crm.entiy.business.BusinessFlowDO;
import pers.lx.crm.entiy.business.FlowDO;

import java.util.List;

/**
 * Created by lxl on 2017/3/8.
 */
@Repository
public interface BusinessDao {

    public void insertBusiness(BusinessDO businessDO) ;

    @Insert("insert into business_flow(business_id,flow_id,flow_order) values(#{businessId},#{flowId},#{flowOrder})")
    public void insertBusinessFlow(BusinessFlowDO businessFlowDO) ;

    @Update("update business set name=#{name},description=#{description},price=#{price} where id=#{id}")
    public void updateBusiness(BusinessDO businessDO) ;

    @Select("select * from business")
    public List<BusinessDO> selectBusinessListPage(BusinessDO businessDO) ;

    @Select("select flow.id as id, flow.name as name, flow.description as description from flow,business_flow where business_flow.flow_id = flow.id and business_flow.business_id=#{businessId} order by business_flow.flow_order asc")
    public List<FlowDO> selectFlow(int businessId) ;

    @Select("select * from business_flow where business_id=#{businessId}")
    public List<BusinessFlowDO> selectBusinessFlow(int businessId) ;

    @Delete("delete from business where id=#{id}")
    public  void deleteBusiness(BusinessDO businessDO) ;

    @Delete("delete from business_flow where business_id=#{businessId}")
    public void deleteBusinessFlow(int businessId) ;

}
